package com.buba.aspect.controller;

import com.buba.aspect.pojo.Log;
import com.buba.aspect.service.LogService;
import com.buba.system.pojo.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping("/Log")
@RestController
public class LogController {
    @Autowired
    @Qualifier("logServiceImpl")
    private LogService logService;

    @RequestMapping("selLog")
    public Page selLog(@RequestParam Map<String, Object> map, String employeeId){
        Page page = new Page((Integer.parseInt(map.get("pageNow").toString())),(Integer.parseInt(map.get("pageCount").toString())));
        map.put("page", page);
        map.put("employeeId", employeeId);
        List<Log> list = null;
        if (employeeId==null || employeeId=="") {
            //查询客户总条数b
            page.computePageTotal( logService.selLogCount());

            //查询所有客户信息
            list = logService.selLog(page);
        } else { // 携带查询条件
            //查询客户总条数b
            page.computePageTotal(logService.selLogCountByName(map));
            //查询所有客户信息
            list = logService.selLogByName(map);
        }
        page.setList(list);
        return page;
    }
}
